class Solution(object):
    def findNthDigit(self, n):
        """
        :type n: int
        :rtype: int
        """

        if n <= 9:
            return n
        base = 9
        total = 0
        count = 0
        while total + base * (count + 1) < n:
            total += base * (count + 1)
            count += 1
            base *= 10
        n = n - total
        m = (n - 1) // (count + 1)
        v = n - m * (count + 1)
        num = 10 ** count + m
        return int(str(num)[v - 1])


data = Solution()
n = 100
print(data.findNthDigit(n))
